package cn.flc.mapper;



import cn.flc.bean.UserEntity;
import cn.flc.bean.dto.UserDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


/**
 * @author: Xzh
 * @date: 2023/3/3 16:35
 * @description:
 */
@Mapper
public interface UserMapper {
    @Insert("insert into user(nickname,username,email,phone,wechat,user_password,salt,remarks,create_time,update_time,tb_status) values(#{nickname},#{username},#{email},#{phone},#{wechat},#{userPassword},#{salt},#{remarks},#{createTime},#{updateTime},#{tbStatus})")
    void register(UserEntity user);
    @Select("select * from user where email=#{username} or username=#{username} or phone=#{username} or nickname=#{nickname}")
    UserEntity findExist(UserEntity user);
    //or  和 and 的顺序不能错
    @Select("select * from user where user_password=#{userPassword} and email=#{username} or username=#{username} or phone=#{username}  ")
    UserEntity login(UserEntity user);
    @Update("update user set update_time=#{updateTime} where email=#{username} or username=#{username} or phone=#{username} or nickname=#{nickname} ")
    void update(UserEntity user);
    @Select("select * from user where email=#{username} or username=#{username} or phone=#{username} or nickname=#{nickname}")
    UserEntity remind(UserDto user);
}
